<?php $this->load->view('layout/lottery/header') ?>
<div class="lotteryMain">
	<ol class="breadcrumb">
		<li><a href="<?php echo site_url('lottery/index'); ?>">活动列表</a></li>
		<li>编辑活动</li>
	</ol>
	<div class="panel panel-default">
		<div class="panel-heading">编辑活动</div>
		<div class="panel-body">
	  		<form class="form-horizontal form-editlotery" id="lottery-form" method="post" action="<?php echo site_url('lottery/lotteryEditPost') ?>" enctype="multipart/form-data">
	  			<input type="hidden" name="lottery_id" value="<?php echo $lottery->lottery_id; ?>">
	  			<div class="clearfix form-text">
					<div class="form-group clearfix w2">
					    <label class="control-label"><i class="require">*</i>活动名称</label>
					    <input type="text" name="lottery_name" class="form-control txt" placeholder="请输入活动名称" value="<?php echo $lottery->lottery_name; ?>">
					    <span class="error"></span>
					</div>
					<div class="form-group clearfix w2">
					    <label class="control-label"><i class="require">*</i>活动状态</label>
					    <select name="status">
					    	<option value="1">上架</option>
					    	<option value="2">下架</option>
					    </select>
					    <span class="error"></span>
					</div>
					<div class="form-group clearfix w2">
					    <label class="control-label"><i class="require">*</i>抽奖次数</label>
					    <input type="text" name="lottery_sum" class="form-control txt" placeholder="请输入抽奖次数" value="<?php echo $lottery->lottery_sum; ?>">
					    <span class="error"></span>
					</div>
					<div class="form-group clearfix w2">
					    <label class="control-label"><i class="require">*</i>中奖次数</label>
					    <input type="text" name="winning_num" class="form-control txt" placeholder="请输入中奖次数" value="<?php echo $lottery->winning_num; ?>">
					    <span class="error"></span>
					</div>
					<div class="form-group clearfix w2">
					    <label class="control-label"><i class="require">*</i>开始日期</label>
					    <input type="text" name="start_date" class="form-control txt" placeholder="请输入抽奖开始日期" onclick="calendar.show({ id: this, minDay : '<?php echo date('Y-m-d'); ?>' })" value="<?php echo ($lottery->start_date > '2016-05-01') ? substr($lottery->start_date, 0, 10) : date('Y-m-d'); ?>" readonly="true" >
					    <span class="error"></span>
					</div>
					<div class="form-group clearfix w2">
					    <label class="control-label"><i class="require">*</i>截止日期</label>
					    <input type="text" name="end_date" class="form-control txt" placeholder="请输入抽奖截止日期" onclick="calendar.show({ id: this, minDay : '<?php echo date('Y-m-d'); ?>' })" value="<?php echo ($lottery->end_date > '2016-05-01') ? substr($lottery->end_date, 0, 10) : date('Y-m-d'); ?>" readonly="true">
					    <span class="error"></span>
					</div>
					<?php $titles = json_decode($lottery->titles); ?>
					<div class="form-group clearfix w2">
					    <label class="control-label">活动标题1</label>
					    <input type="text" class="form-control txt" name="title1" placeholder="请输入少于9个字标题" value="<?php echo isset($titles->title1) ? $titles->title1 : ''; ?>" />
					    <span class="error"></span>
					</div>
					<div class="form-group clearfix w2">
					    <label class="control-label">活动标题2</label>
					    <input type="text" class="form-control txt" name="title2" placeholder="请输入少于9个字标题" value="<?php echo isset($titles->title2) ? $titles->title2 : ''; ?>" />
					    <span class="error"></span>
					</div>
					<div class="form-group clearfix lot-tit">
					    <label class="control-label">活动标题3</label>
					    <input type="text" class="form-control txt" name="title3" placeholder="请输入少于21个字标题" value="<?php echo isset($titles->title3) ? $titles->title3 : '' ; ?>" />
					    <span class="error"></span>
					</div>
					<div class="form-group clearfix w1">
					    <label class="control-label"><i class="require">*</i>活动坐标</label>
					    <label class="radio-inline">
				        	<input type="radio" name="on_line" value="1" <?php echo ($lottery->on_line == 1) ? 'checked="checked"' : ''; ?> />
				          线上
				        </label>
				        <label class="radio-inline">
				        	<input type="radio" name="on_line" value="2" <?php echo ($lottery->on_line == 2) ? 'checked="checked"' : ''; ?> />
				          现场
				        </label>
					</div>
					<div class="form-group clearfix w1 recommend <?php echo ($lottery->on_line == 1) ? 'my-hide' : ''; ?>">
					    <label class="control-label">指定用户</label>
					    <div class="recommend-list">
					    	<?php if ($reseller->num_rows() > 0) : ?>
					    	<?php foreach($reseller->result() as $value) : ?>
						    <span class="recommend-item">
							    <input type="text" class="form-control txt" name="reseller_name[]" value="<?php echo $value->reseller_name; ?>" placeholder="请输入推荐账号"/>
							    <a href="javascript:;">删除</a>
						    </span>
							<?php endforeach; ?>
							<?php endif; ?>
					    </div>
					    <button class="btn btn-default recommend-btn">新增推荐账号</button>
					</div>
					<?php $details = json_decode($lottery->details); ?>
					<div class="form-group clearfix w1">
						<label class="control-label">推广链接</label>
						<input type="text" name="links" class="form-control txt" value="<?php echo isset($details->links) ? $details->links : '' ; ?>">
					</div>
					<div class="form-group clearfix w1">
						<label class="control-label">活动详情</label>
						<textarea name="content"><?php echo isset($details->content) ? $details->content : ''; ?></textarea>
					</div>
					<?php $adverts = json_decode($lottery->adverts); ?>
					<div class="form-group clearfix w1">
						<label class="control-label">广告链接1</label>
						<input type="text" name="ad_links1" class="form-control txt" value="<?php echo isset($adverts->ad_links1) ? $adverts->ad_links1 : '' ; ?>">
					</div>
					<div class="form-group clearfix prize-file w1">
					    <label class="control-label">广告位</label>
						<?php if( isset($adverts->ad_image1) && is_file($this->config->upload_image_path('lotteryPrize', $adverts->ad_image1))):?>
	                        <img src="<?php echo $this->config->show_image_url($adverts->ad_image1);?>" />
	                        <input type="hidden" name="oldfilename1" value="<?php echo $adverts->ad_image1;?>"/>
	                        <input type="file" name="ad_image1" value="<?php echo $adverts->ad_image1;?>" />
	                    <?php else:?>
	                        <input type="file" name="ad_image1"/>
	                    <?php endif;?>
					    <span class="error">注:图片尺寸640x80</span>
				    </div>

					<div class="form-group clearfix w1">
						<label class="control-label">广告链接2</label>
						<input type="text" name="ad_links2" class="form-control txt" value="<?php echo isset($adverts->ad_links2) ? $adverts->ad_links2 : '' ; ?>">
					</div>
					<div class="form-group clearfix prize-file w1">
						<label class="control-label">广告位2</label>
						<?php if( isset($adverts->ad_image2) && is_file($this->config->upload_image_path('lotteryPrize', $adverts->ad_image2))):?>
	                        <img src="<?php echo $this->config->show_image_url($adverts->ad_image2);?>" />
	                        <input type="hidden" name="oldfilename2" value="<?php echo $adverts->ad_image2;?>"/>
	                        <input type="file" name="ad_image2" value="<?php echo $adverts->ad_image2;?>" />
	                    <?php else:?>
	                        <input type="file" name="ad_image2"/>
	                    <?php endif;?>
					    <span class="error">注:图片尺寸576x153</span>
				    </div>
				    <?php $winersDetail = json_decode($lottery->winners_details_pages); ?>
				    <div class="form-group clearfix w1">
						<label class="control-label">金币使用链接</label>
						<input type="text" name="bonus_links" class="form-control txt" value="<?php echo isset($winersDetail->bonus_links) ? $winersDetail->bonus_links : ''; ?>">
						<span class="error"></span>
					</div>
					<div class="form-group clearfix link lot-tit">
					    <label class="control-label">活动链接地址</label>
					    <span><?php echo $this->config->m_base_url, 'home/lottery/index.html?id=', $lottery->lottery_id; ?></span>
					</div>
				</div>
				<div class="clearfix form-btns">
					<input type="submit" value="保存" class="btn btn-submit" />
					<a class="btn btn-gray" href="<?php echo site_url('lottery/index'); ?>" />返回</a>
				</div>
			</form>
		</div>
	</div>
</div>
<?php $this->load->view('layout/lottery/footer') ?>
<?php $this->load->view('layout/lottery/message') ?>